/*
 * Copyright (c) JiaChaoYang 2023-7-27 MongoPlus版权所有
 * 适度编码益脑，沉迷编码伤身，合理安排时间，享受快乐生活。
 * email: j15030047216@163.com
 * phone: 15030047216
 * weChat: JiaChaoYang_
 */

package com.anwen.mongoa.service.impl;

import com.anwen.mongo.annotation.datasource.MongoDs;
import com.anwen.mongo.annotation.transactional.MongoTransactional;
import com.anwen.mongo.conditions.aggregate.AggregateChainWrapper;
import com.anwen.mongo.conditions.aggregate.LambdaAggregateChainWrapper;
import com.anwen.mongo.conditions.query.LambdaQueryChainWrapper;
import com.anwen.mongo.conditions.query.QueryChainWrapper;
import com.anwen.mongo.conditions.update.LambdaUpdateChainWrapper;
import com.anwen.mongo.conditions.update.UpdateChainWrapper;
import com.anwen.mongo.model.PageParam;
import com.anwen.mongo.model.PageResult;
import com.anwen.mongo.service.impl.ServiceImpl;
import com.anwen.mongo.support.SFunction;
import com.anwen.mongoa.entity.MongoTest;
import com.anwen.mongoa.service.MongoService;
import com.mongodb.client.model.CreateIndexOptions;
import com.mongodb.client.model.DropIndexOptions;
import com.mongodb.client.model.IndexModel;
import com.mongodb.client.model.IndexOptions;
import org.bson.Document;
import org.bson.conversions.Bson;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

/**
 * @author JiaChaoYang
 * @project mongo-plus-demo
 * @description
 * @date 2023-07-18 22:27
 **/
@Service
public class MongoServiceImpl extends ServiceImpl<MongoTest> implements MongoService {


    @Override
    @MongoDs("server")
    public Boolean save(MongoTest entity) {
        return super.save(entity);
    }

    @Override
    public Boolean saveBatch(Collection<MongoTest> entityList) {
        return super.saveBatch(entityList);
    }

    @Override
    public Boolean saveOrUpdate(MongoTest entity) {
        return super.saveOrUpdate(entity);
    }

    @Override
    public Boolean saveOrUpdateWrapper(MongoTest entity, QueryChainWrapper<MongoTest, ?> queryChainWrapper) {
        return super.saveOrUpdateWrapper(entity, queryChainWrapper);
    }


    @Override
    public Boolean saveOrUpdateBatch(Collection<MongoTest> entityList) {
        return super.saveOrUpdateBatch(entityList);
    }

    @Override
    public Boolean saveOrUpdateBatchWrapper(Collection<MongoTest> entityList, QueryChainWrapper<MongoTest, ?> queryChainWrapper) {
        return super.saveOrUpdateBatchWrapper(entityList, queryChainWrapper);
    }

    @Override
    public Boolean updateById(MongoTest entity) {
        return super.updateById(entity);
    }


    @Override
    public Boolean updateBatchByIds(Collection<MongoTest> entityList) {
        return super.updateBatchByIds(entityList);
    }

    @Override
    public Boolean updateByColumn(MongoTest entity, SFunction<MongoTest, Object> column) {
        return super.updateByColumn(entity, column);
    }

    @Override
    public Boolean updateByColumn(MongoTest entity, String column) {
        return super.updateByColumn(entity, column);
    }

    @Override
    public Boolean remove(UpdateChainWrapper<MongoTest, ?> updateChainWrapper) {
        return super.remove(updateChainWrapper);
    }

    @Override
    public Boolean update(UpdateChainWrapper<MongoTest, ?> updateChainWrapper) {
        return super.update(updateChainWrapper);
    }

    @Override
    public Boolean update(MongoTest entity, QueryChainWrapper<MongoTest, ?> queryChainWrapper) {
        return super.update(entity, queryChainWrapper);
    }

    @Override
    public Boolean removeById(Serializable id) {
        return super.removeById(id);
    }

    @Override
    public Boolean removeByColumn(SFunction<MongoTest, Object> column, Object value) {
        return super.removeByColumn(column, value);
    }

    @Override
    public Boolean removeByColumn(String column, Object value) {
        return super.removeByColumn(column, value);
    }

    @Override
    public Boolean removeBatchByIds(Collection<? extends Serializable> idList) {
        return super.removeBatchByIds(idList);
    }

    @Override
    public List<MongoTest> aggregateList(AggregateChainWrapper<MongoTest, ?> queryChainWrapper) {
        return super.aggregateList(queryChainWrapper);
    }

    @Override
    public MongoTest one(QueryChainWrapper<MongoTest, ?> queryChainWrapper) {
        return super.one(queryChainWrapper);
    }

    @Override
    public List<MongoTest> list() {
        return super.list();
    }

    @Override
    public List<MongoTest> list(QueryChainWrapper<MongoTest, ?> queryChainWrapper) {
        return super.list(queryChainWrapper);
    }

    @Override
    public List<MongoTest> list(AggregateChainWrapper<MongoTest, ?> queryChainWrapper) {
        return super.list(queryChainWrapper);
    }

    @Override
    public long count() {
        return super.count();
    }

    @Override
    public long count(QueryChainWrapper<MongoTest, ?> queryChainWrapper) {
        return super.count(queryChainWrapper);
    }

    @Override
    public PageResult<MongoTest> page(QueryChainWrapper<MongoTest, ?> queryChainWrapper, Integer pageNum, Integer pageSize) {
        return super.page(queryChainWrapper, pageNum, pageSize);
    }

    @Override
    public PageResult<MongoTest> page(QueryChainWrapper<MongoTest, ?> queryChainWrapper, PageParam pageParam) {
        return super.page(queryChainWrapper, pageParam);
    }

    @Override
    public PageResult<MongoTest> page(QueryChainWrapper<MongoTest, ?> queryChainWrapper, Integer pageNum, Integer pageSize, Integer recentPageNum) {
        return super.page(queryChainWrapper, pageNum, pageSize, recentPageNum);
    }

    @Override
    public PageResult<MongoTest> page(QueryChainWrapper<MongoTest, ?> queryChainWrapper, PageParam pageParam, Integer recentPageNum) {
        return super.page(queryChainWrapper, pageParam, recentPageNum);
    }

    @Override
    public List<MongoTest> pageList(PageParam pageParam) {
        return super.pageList(pageParam);
    }

    @Override
    public List<MongoTest> pageList(Integer pageNum, Integer pageSize) {
        return super.pageList(pageNum, pageSize);
    }

    @Override
    public List<MongoTest> pageList(QueryChainWrapper<MongoTest, ?> queryChainWrapper, Integer pageNum, Integer pageSize) {
        return super.pageList(queryChainWrapper, pageNum, pageSize);
    }

    @Override
    public List<MongoTest> pageList(QueryChainWrapper<MongoTest, ?> queryChainWrapper, PageParam pageParam) {
        return super.pageList(queryChainWrapper, pageParam);
    }

    @Override
    public PageResult<MongoTest> page(PageParam pageParam) {
        return super.page(pageParam);
    }

    @Override
    public PageResult<MongoTest> page(PageParam pageParam, Integer recentPageNum) {
        return super.page(pageParam, recentPageNum);
    }

    @Override
    public PageResult<MongoTest> page(Integer pageNum, Integer pageSize) {
        return super.page(pageNum, pageSize);
    }

    @Override
    public PageResult<MongoTest> page(Integer pageNum, Integer pageSize, Integer recentPageNum) {
        return super.page(pageNum, pageSize, recentPageNum);
    }

    @Override
    public MongoTest getById(Serializable id) {
        return super.getById(id);
    }

    @Override
    public List<MongoTest> getByIds(Collection<? extends Serializable> ids) {
        return super.getByIds(ids);
    }

    @Override
    public List<MongoTest> queryCommand(String command) {
        return super.queryCommand(command);
    }

    @Override
    public List<MongoTest> getByColumn(SFunction<MongoTest, Object> field, Object fieldValue) {
        return super.getByColumn(field, fieldValue);
    }

    @Override
    public List<MongoTest> getByColumn(String field, Object fieldValue) {
        return super.getByColumn(field, fieldValue);
    }

    @Override
    public Boolean exist(Serializable id) {
        return super.exist(id);
    }

    @Override
    public Boolean exist(QueryChainWrapper<MongoTest, ?> queryChainWrapper) {
        return super.exist(queryChainWrapper);
    }

    @Override
    public String createIndex(Bson bson) {
        return super.createIndex(bson);
    }

    @Override
    public String createIndex(Bson bson, IndexOptions indexOptions) {
        return super.createIndex(bson, indexOptions);
    }

    @Override
    public List<String> createIndexes(List<IndexModel> indexes) {
        return super.createIndexes(indexes);
    }

    @Override
    public List<String> createIndexes(List<IndexModel> indexes, CreateIndexOptions createIndexOptions) {
        return super.createIndexes(indexes, createIndexOptions);
    }

    @Override
    public List<Document> listIndexes() {
        return super.listIndexes();
    }

    @Override
    public void dropIndex(String indexName) {
        super.dropIndex(indexName);
    }

    @Override
    public void dropIndex(String indexName, DropIndexOptions dropIndexOptions) {
        super.dropIndex(indexName, dropIndexOptions);
    }

    @Override
    public void dropIndex(Bson keys) {
        super.dropIndex(keys);
    }

    @Override
    public void dropIndex(Bson keys, DropIndexOptions dropIndexOptions) {
        super.dropIndex(keys, dropIndexOptions);
    }

    @Override
    public void dropIndexes() {
        super.dropIndexes();
    }

    @Override
    public void dropIndexes(DropIndexOptions dropIndexOptions) {
        super.dropIndexes(dropIndexOptions);
    }

    @Override
    public Class<MongoTest> getClazz() {
        return super.getClazz();
    }

    @Override
    public LambdaQueryChainWrapper<MongoTest> lambdaQuery() {
        return super.lambdaQuery();
    }

    @Override
    public LambdaAggregateChainWrapper<MongoTest> lambdaAggregate() {
        return super.lambdaAggregate();
    }

    @Override
    public LambdaUpdateChainWrapper<MongoTest> lambdaUpdate() {
        return super.lambdaUpdate();
    }

    @Override
    @MongoTransactional
    public void testTx(MongoTest mongoTest, MongoTest test) {
        super.save(mongoTest);
        if (Objects.nonNull(mongoTest)) {
            throw new NullPointerException();
        }
        super.save(test);
    }

}
